/*************************************************************************
	> File Name: DataInput_OutputStreamTest.java
	> Author: Potter
	> Mail: tobewhatwewant@gmail.com 
	> Created Time: 2014年06月02日 星期一 01时19分59秒
 ************************************************************************/
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.FileOutputStream;
import java.io.FileInputStream;

public class DataInput_OutputStreamTest {
    public static void main(String[] args) throws Exception {
        write();
        read();
    }

    static void write() throws Exception {
        DataOutputStream dos = new DataOutputStream(new FileOutputStream("tmp.txt"));
        dos.writeInt(20);
        dos.writeByte(2);
        dos.writeBoolean(false);
        dos.writeUTF("world");
    }

    static void read() throws Exception {
        DataInputStream dis = new DataInputStream(new FileInputStream("tmp.txt"));
        System.out.println(dis.readInt());
        System.out.println(dis.readByte());
        System.out.println(dis.readBoolean());
        System.out.println(dis.readUTF());
    }
}
